<?php 
	class models_loaihang extends connect{
		function listLoaiHang(){
			$sql = "SELECT MaLH,MaCL,TenLH
					FROM loaihang";
			$this->query_db($sql);
			return $this->fetchAll();
		}
		
				
		function addLoaiHang($MaCL,$TenLH){
			$sql = "INSERT INTO loaihang VALUES ('','$MaCL','$TenLH')";
			$this->query_db($sql);
			
		}
		
		function delLoaiHang($intMa){
			$sql = "DELETE
					FROM loaihang
					WHERE MaLH = '$intMa'";
			$this->query_db($sql);	
		}
		function getLoaiHang($intMa)
		{
			$sql = "SELECT MaCL, MaLH, TenLH
					FROM loaihang 
					WHERE MaLH = '$intMa'";
			
			$this->query_db($sql);
			return $this->fetchOne();
		}
	
		
		function updateLoaiHang($MaCL,$TenLH,$ma)
		{
			$sql ="	UPDATE loaihang
					SET 
						MaCL='$MaCL', 
						TenLH = '$TenLH'
					WHERE MaLH = '$ma'";
			$this->query_db($sql);
		}
		
			
	}
	